﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VehicleTrajectoryApp
{
    public struct GPSpoint
    {
        public double x;
        public double y;
    };

    class Changecoordinates
    {
        public static double m_XScale = 1;
        public static double m_YScale = 1;
        public static double m_XOrigin = 0;
        public static double m_YOrigin = 0;

        public double original_point1_x;
        public double original_point1_y;
        public double original_point2_x;
        public double original_point2_y;
        public double changed_point1_x;
        public double changed_point1_y;
        public double changed_point2_x;
        public double changed_point2_y;

        public Changecoordinates(double original_point1_x, double original_point1_y, double original_point2_x, double original_point2_y, double changed_point1_x, double changed_point1_y, double changed_point2_x, double changed_point2_y)
        {
            m_XScale = (changed_point1_x - changed_point2_x) / (original_point1_x - original_point2_x);
            m_YScale = (changed_point1_y - changed_point2_y) / (original_point1_y - original_point2_y);
            m_XOrigin = original_point1_x - changed_point1_x / m_XScale;
            m_YOrigin = original_point1_y - changed_point1_y / m_YScale;
        }
        public GPSpoint ChangeCoordinatesSystem(double new_point_X, double new_point_Y)
        {
            GPSpoint pt;
            pt.x = (new_point_X - m_XOrigin) * m_XScale;
            pt.y = (new_point_Y - m_YOrigin) * m_YScale;
            return pt;
        }
    }
}
